home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / os2 / inadv095.zip / qexport.cmd < prev    next >
OS/2 REXX Batch file  |  1996-08-14  |  3KB  |  117 lines

  1. /*
  2. ------------------------
  3. Test Quicklist routines
  4. ------------------------
  5. */
  6.  
  7. TEMPFILE = "quicklst.txt"
  8.  
  9. say "Trying to load/register Internet Adventurer REXX API"
  10. if RxFuncQuery("IARX_Register") <> 0 then do
  11.    rc = RxFuncAdd("IARX_Register","IA_UTILS","IARX_Register")
  12.    if rc <> 0 then do
  13.       say "-------------------------------------"
  14.       say "Error loading Internet Adventurer API"
  15.       say "-------------------------------------"
  16.       exit(1)
  17.    end
  18. end
  19.  
  20. rc = IARX_Register();
  21. if rc then do
  22.    say "-------------------------------------"
  23.    say "Error loading Internet Adventurer API"
  24.    say "-------------------------------------"
  25.    exit(1)
  26. end
  27.  
  28. say "Opening database"
  29. ptr = IARX_QOpenDatabase();
  30. if length(ptr) > 0 then do
  31.    say "-------------------------------------"
  32.    say "Opening database gave this:" ptr
  33.    say "-------------------------------------"
  34.    exit(1)
  35. end
  36.  
  37. say "Database opened"
  38.  
  39. address cmd 'del' TEMPFILE '>NUL'
  40.  
  41. rc = lineout(TEMPFILE,,1)
  42.  
  43. signal on novalue name handlenovalue
  44. signal on error   name handleerror
  45. signal on syntax  name handleerror
  46.  
  47. call show_tree 0 0
  48.  
  49. say "Closing database"
  50. rc = IARX_QCloseDatabase()
  51.  
  52. rc = lineout(TEMPFILE)
  53.  
  54. say "Exporting completed - look in" TEMPFILE
  55. exit(0)
  56.  
  57. show_tree: procedure expose TEMPFILE
  58.    arg id level
  59.  
  60.    rc = IARX_QMakeTree("t", id);
  61.    if rc = 0 then do
  62.       do i = 1 to t.items by 1
  63.          str = copies(' ', level) || "Title:" '"' || t.i.title || '"'
  64.          rc = lineout(TEMPFILE, str)
  65.  
  66.          if t.i.type = 1 then do
  67.             rc = lineout(TEMPFILE, copies(' ', level) || "URL  :" '"' || t.i.url || '"') 
  68.  
  69.             if datatype(t.i.nick, "Number") = 1 then
  70.                rc = lineout(TEMPFILE, copies(' ', level) || 'Nick : ""')
  71.             else
  72.                rc = lineout(TEMPFILE, copies(' ', level) || "Nick :" '"' || t.i.nick || '"')
  73.          end
  74.          else do
  75.             call show_tree t.i.id level+1
  76.          end
  77.       end
  78.    end
  79.  
  80.    drop t
  81.    return
  82.  
  83. /*
  84. -------------
  85. Handle errors
  86. -------------
  87. Upon entry to this function, the contents of the variables are:
  88. rc   - Error code
  89. sigl - Line number, error occured in.
  90.  
  91. Now we just display the error code and text followed by the
  92. source-line with the problem
  93. */
  94.  
  95. handleerror:
  96.  
  97. say "REXX Error" rc "in line" sigl ":" errortext(rc);
  98. say "-----";
  99. say "-----" sourceline(sigl);
  100. say "-----";
  101. rc = IARX_QCloseDatabase();
  102. exit;
  103.  
  104. /*
  105. ------------------------------
  106. Handle variables without value
  107. ------------------------------
  108. */
  109. handlenovalue:
  110.  
  111. say "REXX Error, trying to reference variable with no value in line" sigl;
  112. say "-----";
  113. say "-----" sourceline(sigl);
  114. say "-----";
  115. rc = IARX_QCloseDatabase();
  116. exit;
  117.